<template>
    <div class="person">
        <h3>看谁来过**</h3>
        <div class="user">
            <p class="normal" v-if="!person.length">还没人来过...</p>
            <span v-bgColor v-else v-for="item in person" :key="item">{{item}}</span>
        </div>
    </div>
</template>

<script>
export default {
    data(){
        return {
            person:[]
        }
    },
    methods:{
        getData(){
            this.$axios.get("/person")
            .then(res=>{
                // console.log(res.data)
                this.person=res.data
            })
        }
    },
    activated(){
        this.getData()
    },
    directives:{
        bgColor(el){
            el.style.backgroundColor=`#${Math.random().toString(16).slice(2,8)}`
        }
    }
}
</script>

<style lang="less" scoped>
.person{
    box-sizing: border-box;
    padding:10px 20px 25px;
    width:100%;
    margin-top:30px;
    background:white;
    h3{
        position:relative;
        line-height: 50px;
        border-bottom: 1px solid #e8e9e7;
        font-size:16px;
        color:#666;
        &::after{
            position: absolute;
            left:-20px;
            top:23%;
            content:"";
            display:block;
            width:6px;
            height:25px;
            background:#83e1f7;
            border-top-right-radius: 20px;
            border-bottom-right-radius: 20px;
        }
    }
    .user{
        box-sizing: border-box;
        padding-top:10px;
        span{
            display:inline-block;
            width:50px;
            height:50px;
            margin-left:13px;
            margin-bottom:10px;
            border-radius: 50%;
            line-height: 50px;
            text-align: center;
        }
    }
}
</style>